package com.skycode5.servlet;

import com.skycode5.bean.NewsBean;
import com.skycode5.dao.NewsDao;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/newsAdd.jsp")
public class NewsServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException{
        String P = req.getParameter("page");
        //todo 获取分页页码参数
        // 1. 获取新闻信息
        NewsDao newsDao = new NewsDao();
        List<NewsBean> news =newsDao.getLIst();
        // 2 .传递新闻信息给前端页面
        req.setAttribute("news",news);
        // 3. 加载显示前端页面
        req.getRequestDispatcher("newstemp.jsp").forward(req, resp);
    }
}

